#pragma once
#include <string>
#include <map>
#include <assert.h>
class CClip {
public:
    //void update(float dt);
    CClip();
    virtual ~CClip() {};
    float mCurrentTime;
    float mTotalTime;

    float mGlobalTime;
    float mGlobalTotalTime;
    bool mRepeat;
    bool mGlobal;
    bool mStopped;
    std::string mTimeFunction;
    void addNumber(const std::string &paramName, double value) {
        mNumbers[paramName] = value;
    }
    double getNumber(const std::string &paramName, double defaultValue) const{
        std::map<std::string, double>::const_iterator iter;
        if ( ( iter = mNumbers.find(paramName)) != mNumbers.end()) {
            return iter->second;
        }
        else {
            return defaultValue;
        }
    }
    void addString(const std::string &paramName, const std::string &str) {
        mStrings[paramName] = str;
    }
    std::string getString(const std::string &paramName, const std::string &defaultString) const{
        std::map<std::string, std::string>::const_iterator iter;
        if ( ( iter = mStrings.find(paramName)) != mStrings.end()) {
            return iter->second;
        }
        else {
            return defaultString;
        }
    }
    virtual void update(float dt);
protected:
    std::map<std::string, double> mNumbers;
    std::map<std::string, std::string> mStrings;
    //void load(const std::string &filename, struct lua_State *L);
};

class CClipManager {
public:
    CClipManager(){};
    ~CClipManager(){
        ClipMap::iterator iter;
        for (iter = mClips.begin(); iter != mClips.end(); ++iter) {
            delete iter->second;
        }
    }
    typedef std::map<std::string, CClip*> ClipMap;

    //template<class T>
    CClip* createClip(const std::string& name) {
        CClip * pClip =/* dynamic_cast<CClip*>*/(new CClip);
        assert(pClip);
        mClips[name] = pClip;
        return pClip;
    }
    ClipMap mClips;
};